package com.demo.mysql.base;

import org.springframework.context.annotation.Bean;

import java.util.Map;

/**
 * @author hushengdong
 */
public abstract class MultipleDataSourceConfig extends DataSourceConfig {

    public MultipleDataSourceConfig() {
    }

    @Bean
    public MultipleDataSource multipleDataSource() throws Exception {
        MultipleDataSource multipleDataSource = new MultipleDataSource();
        multipleDataSource.setDefaultTargetDataSource(this.getDefaultTargetDataSource());
        multipleDataSource.setTargetDataSources(this.getAllDataSource());
        return multipleDataSource;
    }

    protected abstract Map<Object, Object> getAllDataSource() throws Exception;

    protected abstract Object getDefaultTargetDataSource() throws Exception;
}
